<?php

namespace addons\yunfood\model;

use addons\yunfood\library\ModelTrait;
use think\Model;
use traits\model\SoftDelete;

/**
 * 导入日志
 */
class ImportLog extends Model
{
    use ModelTrait;
    use SoftDelete;

    // 表名,不含前缀
    protected $name = 'yunfood_import_log';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;

    // 定义时间戳字段名
    protected $deleteTime = 'deleted_at';
    protected $updateTime = 'updated_at';
    protected $createTime = 'created_at';

    // 不显示的字段
    protected $hidden = ['deleted_at'];

    protected $resultSetType = 'collection';

    // 场景
    const SCENE_SHOP_DESK = 'shop_desk';

    public static function getSceneList()
    {
        return [
            self::SCENE_SHOP_DESK => __('桌号导入'),
        ];
    }

    public function getSceneTextAttr($value, $data)
    {
        $optionList = self::getSceneList();

        return $optionList[$data['scene']] ?? $data['scene'];
    }

    // 状态
    const STATUS_HANDLE = 1;
    const STATUS_FINISH = 2;

    public static function getStatusList()
    {
        return [self::STATUS_HANDLE => __('未完成'), self::STATUS_FINISH => __('已完成')];
    }

    public function getStatusTextAttr($value, $data)
    {
        $optionList = self::getStatusList();

        return $optionList[$data['status']] ?? $data['status'];
    }
}
